package com.hjy.controller;

import com.hjy.common.result.Result;
import com.hjy.common.result.User;
import com.hjy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 发送手机号
     */
    @GetMapping("/send/{tel}")
    public Result<User> send(@Validated @PathVariable("tel") String tel) {
        Result<User> user = userService.send(tel);
        return user;
    }

    /**
     * 登录
     */
    @PostMapping("/login")
    public Result<User> login(@Validated @RequestBody User user) {
        Result<User> login = userService.login(user);
        return login;
    }

    /**
     * 获取登录人信息
     */
    @GetMapping("/user/info")
    public Result<User> getUserInfo() {
        User user = userService.getUserInfo();
        return Result.success(user);
    }

}
